#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Create by zhang
# Create on 2022/7/26 17:44
from enum import IntEnum

from infrastructure.utils.result_wrap import ResponseWrapper


class ValidatorModeEnum(IntEnum):
    ATOM = 0
    ENTITY = 1
    ALL = 2


class ValidatorInterface:
    def __init__(self):
        self.mode = ValidatorModeEnum.ALL

    def validate(self, value, mode:ValidatorModeEnum= ValidatorModeEnum.ALL) -> ResponseWrapper:
        if self.mode == ValidatorModeEnum.ALL or self.mode == mode:
            return self.validator__(value)
        else:
            return ResponseWrapper.success()

    def validator__(self, value) -> ResponseWrapper:
        raise NotImplementedError("validator__ 需要有子类实现")